import router from '@/router';
import {pickBy} from "lodash/object.js";
import {identity} from "lodash/util.js";
import {useTagStore} from "@/store/index.js";

const tagStore = useTagStore()
export function updateQuery(newQueryParams, withoutFields = []) {
    const query = pickBy(newQueryParams, (val, key) => {
        if (['page', 'pageSize', 'refresh_tabs', 'scence'].concat(withoutFields).indexOf(key) > -1) {
            return false
        }
        if( key === 'keywords_type' && val === 'keywords'){
            return false
        }
        return identity(val)
    })
    router.replace({ path: '/document/shipment', query: query});
    tagStore.updateTag({
        path: '/document/shipment',
        query
    })
}

export function getQuery() {
    console.log(router.currentRoute.value.query,'router.currentRoute.value.query')
    return router.currentRoute.value.query
}
